//
//  LJSectionSegHeaderView.m
//  BaseProject
//
//  Created by 王洋 on 2021/1/6.
//  Copyright © 2021 王洋. All rights reserved.
//

#import "LJSectionSegHeaderView.h"

@implementation LJSectionSegHeaderView

- (void)awakeFromNib {
    [super awakeFromNib];

    [self.moreControl addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        if (self.LJHeaderViewBlock) {
            self.LJHeaderViewBlock(LJSectionSegHeaderActionType_more);
        }
    }];
}

- (void)fillWithType:(LJSectionSegHeaderActionType)type {
    
    switch (type) {
        case LJSectionSegHeaderActionType_hot:{
            
            [self.hotestBtn setBackgroundColor:UIColorHex(0xffecec)];
            [self.hotestBtn pp_clipCorners:UIRectCornerAllCorners radius:13 border:1 color:UIColorHex(0xffb9b5)];
            [self.hotestBtn setTitleColor:UIColorHex(0xff4242) forState:UIControlStateNormal];
            
            [self.newestBtn setBackgroundColor:UIColorHex(0xF8F9FB)];
            [self.newestBtn pp_clipCorners:UIRectCornerAllCorners radius:13 border:1 color:UIColorHex(0xF8F9FB)];
            [self.newestBtn setTitleColor:UIColorHex(0x333333) forState:UIControlStateNormal];
            
            self.hotestBtn.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
            self.newestBtn.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
            
        } break;
        case LJSectionSegHeaderActionType_new:{
            
            [self.newestBtn setBackgroundColor:UIColorHex(0xffecec)];
            [self.newestBtn pp_clipCorners:UIRectCornerAllCorners radius:13 border:1 color:UIColorHex(0xffb9b5)];
            [self.newestBtn setTitleColor:UIColorHex(0xff4242) forState:UIControlStateNormal];
            
            [self.hotestBtn setBackgroundColor:UIColorHex(0xF8F9FB)];
            [self.hotestBtn pp_clipCorners:UIRectCornerAllCorners radius:13 border:1 color:UIColorHex(0xF8F9FB)];
            [self.hotestBtn setTitleColor:UIColorHex(0x333333) forState:UIControlStateNormal];
            
            self.newestBtn.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
            self.hotestBtn.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
            
        } break;
        default:
            break;
    }
}


- (IBAction)hotAction:(id)sender {
    
    [self.hotestBtn setBackgroundColor:UIColorHex(0xffecec)];
    [self.hotestBtn pp_clipCorners:UIRectCornerAllCorners radius:13 border:1 color:UIColorHex(0xffb9b5)];
    [self.hotestBtn setTitleColor:UIColorHex(0xff4242) forState:UIControlStateNormal];
    
    [self.newestBtn setBackgroundColor:UIColorHex(0xF8F9FB)];
    [self.newestBtn pp_clipCorners:UIRectCornerAllCorners radius:13 border:1 color:UIColorHex(0xF8F9FB)];
    [self.newestBtn setTitleColor:UIColorHex(0x333333) forState:UIControlStateNormal];
    
    if (self.LJHeaderViewBlock) {
        self.LJHeaderViewBlock(LJSectionSegHeaderActionType_hot);
    }
}


- (IBAction)newAction:(id)sender {
    [self.newestBtn setBackgroundColor:UIColorHex(0xffecec)];
    [self.newestBtn pp_clipCorners:UIRectCornerAllCorners radius:13 border:1 color:UIColorHex(0xffb9b5)];
    [self.newestBtn setTitleColor:UIColorHex(0xff4242) forState:UIControlStateNormal];
    
    [self.hotestBtn setBackgroundColor:UIColorHex(0xF8F9FB)];
    [self.hotestBtn pp_clipCorners:UIRectCornerAllCorners radius:13 border:1 color:UIColorHex(0xF8F9FB)];
    [self.hotestBtn setTitleColor:UIColorHex(0x333333) forState:UIControlStateNormal];
    

    if (self.LJHeaderViewBlock) {
        self.LJHeaderViewBlock(LJSectionSegHeaderActionType_new);
    }
}

@end
